

namespace mShare {

	public interface Record : GLib.Object {
		//public abstract bool itunes_compat();
		public abstract GLib.InputStream read();
	}
	
	public enum MediaKind {
		AUDIO,
		VIDEO
	}
	
	public enum QueryType {
		END,
		DISJUNCTION,
		SUBQUERY,

		/* general */
		PROP_EQUALS,
		PROP_NOT_EQUAL,

		/* string */
		PROP_LIKE,
		PROP_NOT_LIKE,
		PROP_PREFIX,
		PROP_SUFFIX,
		
		/* numerical */
		PROP_GREATER,
		PROP_LESS,
	
		/* synthetic query types, translated into non-synthetic ones internally */
		/*PROP_CURRENT_TIME_WITHIN,
		PROP_CURRENT_TIME_NOT_WITHIN,
		PROP_YEAR_EQUALS,
		PROP_YEAR_NOT_EQUAL,
		PROP_YEAR_GREATER,
		PROP_YEAR_LESS*/
	}
	
	public interface QueryData : GLib.Object {
		public abstract QueryType query_type { get; set; }
		public abstract QueryData[] subquery { get; set; }
		public abstract string key { get; set; }
		public abstract Value prop { get; set; }
	}
	
	public interface MediaRecord : GLib.Object {
		public abstract string location { get; set; }
		public abstract string title { get; set; }
		public abstract MediaKind media_kind { get; set; }
		public abstract string songalbum { get; set; }
		public abstract int64 songalbumid { get; set; }
		public abstract string sort_album { get; set; }
		public abstract string songartist { get; set; }
		public abstract string sort_artist { get; set; }
		public abstract string songgenre { get; set; }
		public abstract string format { get; set; }
		public abstract int rating { get; set; }
		public abstract int64 filesize { get; set; }
		public abstract int duration { get; set; }
		public abstract int track { get; set; }
		public abstract int year { get; set; }
		
		//public abstract Gdk.Pixbuf? get_thumbnail (int dimension);
	}

	public interface Db : GLib.Object {
		public abstract Record[] query(QueryData selector, int depth);
		
		public abstract uint add(Record record);
		public abstract uint add_with_id(Record record, uint id);
		public abstract uint add_path(Record record, string path);
		public abstract Record lookup_by_id(uint id);
		public abstract uint lookup_id_by_location(string location);
		public abstract void foreach(GLib.HFunc<uint,GLib.Value?> func);
		public abstract int64 count();
	}
	
	public interface QueryDB : GLib.Object {
		public virtual Record[] query(QueryData selector, int max_depth) {
			int depth = 0;
			//this.foreach((uint, GValue?)) {
				
			//}
			return null;
		}
	}
	
	public interface ContainerRecord {
		public abstract uint get_id();
		public abstract void add_entry(Record record, uint id);
		public abstract uint64 get_entry_count();
		public abstract Db get_entries();
	}

	public interface ContainerDb {
		public abstract ContainerRecord lookup_by_id(uint id);
		public abstract void foreach(GLib.HFunc<uint,GLib.Value?> func);
		public abstract int64 count();
	}
}